﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using FinosLibrary;
namespace BattleShipOnline
{
	public partial class SecondPage : UserControl
	{
        private HomePageLogic logic;
		public SecondPage()
		{
			// Required to initialize variables
			InitializeComponent();
            logic = this.GetInstance<HomePageLogic>();
            textBox.DataContext = ChatText.DataContext = this.GetInstance<Chat>();
            homePage.DataContext = logic;
            UserPanel.DataContext = logic.userModel.self;
            BackImage.Source = Custom.GetBitmapImage("Images/120.jpg");
            Storyboard1.Begin();
		}

		private void button_Click(object sender, System.Windows.RoutedEventArgs e)
		{
            new ChangeFace().Show();
		}

		private void myFace_BindingValidationError(object sender, System.Windows.Controls.ValidationErrorEventArgs e)
		{
            MessageBox.Show(e.Error.Exception.Message);
		}

		private void myFace_ImageFailed(object sender, System.Windows.ExceptionRoutedEventArgs e)
		{
            MessageBox.Show(e.ErrorException.Message);
		}

		private void button_Copy_Click(object sender, System.Windows.RoutedEventArgs e)
		{
            new ChangePassword().Show();
		}

		private void button_Copy1_Click(object sender, System.Windows.RoutedEventArgs e)
		{
            new AddFriends().Show();
		}

		private void textBlock4_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
		{
			// TODO: Add event handler implementation here.
		}

		private void textBox_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
		{
			if(e.Key == Key.Enter){
                textBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
			}
		}

		private void ChatText_LayoutUpdated(object sender, System.EventArgs e)
		{
			ChatText.Select(ChatText.Text.Length,0);
		}
	}
}